package com.example.idachuappone.promptly.entity;

import org.json.JSONObject;

public class Address {
	private String city;
	private String district;
	private String name;

	public Address parseJson(JSONObject json) {
		if (json == null) {
			return null;
		}
		if (json.has("name")) {
			this.name = json.optString("name");
		}
		if (json.has("city")) {
			this.city = json.optString("city");
			if (this.city.replace(" ", "").trim().length() == 0) {
				return null;
			}
		}
		if (!json.has("district")) {
			return this;
		}
		this.district = json.optString("district");
		return this.district.replace(" ", "").trim().length() == 0 ? null : this;
	}

	public Address(String name, String city, String district) {
		this.name = name;
		this.city = city;
		this.district = district;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getDistrict() {
		return this.district;
	}

	public void setDistrict(String district) {
		this.district = district;
	}
}
